/**
 *
 */
package com.winqai.validator;

import com.winqai.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 *
 */
public class MyConstraintValidator implements ConstraintValidator<MyConstraint, Object> {

   @Autowired
   private HelloService helloService;

   @Override
   public void initialize(MyConstraint constraintAnnotation) {
      System.out.println("my validator init");
   }

   /**
    * 校验逻辑
    * @param value
    * @param context
    * @return true 校验成功 false校验失败
    */
   @Override
   public boolean isValid(Object value, ConstraintValidatorContext context) {
      helloService.greeting("tom");
      System.out.println(value);
      return true;
   }

}
